package utgame.com.fakelegendary.model;

import java.text.ParseException;

import utgame.com.fakelegendary.common.SystemUtil;

/**
 * Created by xueal on 2018/1/17.
 */

public class Msg {
    public static final int TYPE_RECEIVED = 0;
    public static final int TYPE_SENT = 1;
    public static final int TYPE_TIME = 2;

    private String content;
    private int type;
    private long time;


    public Msg(String content, int type) {
        this.content = content;
        this.type = type;
        this.time = System.currentTimeMillis();
    }

    public String getContent() {return content;}
    public int getType() {return type;}
    public long getTime() {return time;}

    public static String getChatLogTimeFormat(long timeMillis){
        String time = "";
        try {
            long timeNow = System.currentTimeMillis();
            time = SystemUtil.longToString(timeMillis, "yyyy-MM-dd HH:mm");

            if (timeNow - timeMillis < 12 * 3600 * 1000){
                time = time.split(" ")[1];
            } else {
                time = time.split(" ")[0];
            }

        } catch (ParseException e) {
            e.printStackTrace();
        }
        return time;
    }
}